package leetcode.code0204;

public class Solution extends Solution204 {

	@Override
	public int countPrimes(int n) {
		if (n < 3) {
			return 0;
		}
		int ans = 1;
		for (int i = 3; i < n; i += 2) {
			if (!isPrime(i)) {
				continue;
			}
			ans++;
		}
		return ans;
	}

	private boolean isPrime(int n) {
		for (int i = 2; i * i <= n; i++) {
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
	}

}
